package com.huazhi.wzsnw.service.impl;

import com.huazhi.wzsnw.constant.CommonUser;
import com.huazhi.wzsnw.mapper.LogMapper;
import com.huazhi.wzsnw.model.Log;
import com.huazhi.wzsnw.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import java.util.UUID;

@Service
public class LogServiceImpl implements LogService {
    @Autowired
    private LogMapper logMapper;

    @Override
    public int save(Log record) {
        logMapper.insertSelective(record);
        return 0;
    }

    @Override
    public int delete(Log record) {
        return 0;
    }

    @Override
    public int deletes(List<Log> records) {
        return 0;
    }

    @Override
    public int update(Log record) {
        return 0;
    }

    @Override
    public Log findByTid(String tid) {
        return null;
    }

    @Override
    public List<Log> findPagingByListTid(List<String> stringList, Integer pageIndex, Integer pageSize) {
        return logMapper.findPagingByListTid(stringList,pageIndex,pageSize);
    }

    @Override
    public void getAddLog(String module, String function, String deatil) {
        Log log= new Log();
        log.setTid(UUID.randomUUID().toString());
        log.setUsertid(CommonUser.getUser().getTid());
        log.setModule(module);
        log.setFunction(function);
        log.setDeatil(deatil);
        log.setCreatetime(new Date());
        logMapper.insertSelective(log);
    }

    @Override
    public List<String> getListTid(Date startTime, Date endTime, String key) {
        return logMapper.selectListTid(startTime,endTime,key);
    }
}


